<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:79:"D:\phpstudy_pro\WWW\thinkphp\public/../application/admin\view\config\index.html";i:1647310601;s:68:"D:\phpstudy_pro\WWW\thinkphp\application\admin\view\common\meta.html";i:1647074041;}*/ ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
<title><?php echo $System['SiteName']['value']; ?></title>

<meta name="keywords" content="<?php echo $System['keywords']['value']; ?>" />
<meta name="description" content="<?php echo $System['description']['value']; ?>" />
<link rel="shortcut icon" href="<?php echo $System['SiteLogo']['value']; ?>" />

<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<meta http-equiv="Cache-Control" content="no-siteapp" />

<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="/assets/admin/css/font.css">
<link rel="stylesheet" href="/assets/admin/css/xadmin.css">

<script src="/assets/admin/js/jquery.min.js"></script>
<script src="/assets/admin/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="/assets/admin/js/xadmin.js"></script>
</head>
<body>
    <div class="x-body">
        <xblock>
          <button class="layui-btn layui-btn-danger" onclick="delAll()">
            <i class="layui-icon"></i>批量删除
          </button>
  
          <span class="x-right" style="line-height:40px">
            共有数据：<?php echo $count; ?> 条
          </span>
        </xblock>
  
        <table class="layui-table">
          <thead>
            <tr>
              <th>
                <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
              </th>
              <th>配置的标题</th>
              <th>配置的名称</th>
              <th>配置的类型</th>
              <th>配置的值</th>
              <th>操作</th>
          </thead>
  
          <tbody>
          <?php foreach($countlist as $item): ?>
            <tr>
              <td>
                <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id="<?php echo $item['id']; ?>">
                  <i class="layui-icon">&#xe605;</i>
                </div>
              </td>
              <td><?php echo $item['title']; ?></td>
              <td><?php echo $item['key']; ?></td>
              <?php if($item['type'] == 'text'): ?>
                <td>文本类型</td>
                <td><?php echo $item['value']; ?></td>
              <?php else: ?>
                <td>文件类型</td>
                <td>
                    <img src="<?php echo $item['value']; ?>" alt="">
                </td>
               <?php endif; ?>
                <td>
                    <a title="编辑" href="<?php echo url('admin/config/edit', ['id' => $item['id']]); ?>">
                        <i class="layui-icon">&#xe642;</i>
                    </a>
                    <a title="删除"href="javascript:;" onclick="deletes(`<?php echo $item['id']; ?>`)">
                        <i class="layui-icon">&#xe640;</i>
                    </a>
                </td>
            </tr>
            <?php endforeach; ?>
          </tbody>
        </table>
  
        <div class="page">
            <?php echo $pagestr; ?>
        </div>
  
      </div>
</body>
</html>
<script>
    // 批量删除
    function delAll(){
        var ids = tableCheck.getData()
        layer.confirm('确认要删除吗？',function(index){
            //将数组转换为字符串
            var data = ids.join(',');
            del(data)
        })
    }

    // 单个删除
    function deletes(id){
        layer.confirm('确认要删除吗？',function(index){
            layer.close(index);
            del(id)
        })
    }

    // 调用删除方法
    function del(data){
        //序列化 将对象转换为参数形式
        var params ={
            ids: data
        }
       
        params = $.param(params)

        $.ajax({
            type: "POST",
            url: `<?php echo url('admin/config/del'); ?>`,
            data: params,
            dataType: "json",
            success: function(data){
                layer.msg(data.msg,{icon: 5,time:1000},function(){
                    location.reload()
                })
            }
        })
    }
</script>
